/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sais.eswn.net;

import java.awt.Color;
import org.sais.eswn.core.GameCore;
import org.sais.eswn.tool.Tools;

/**
 *
 * @author Romulus
 */
public class HostMessageDispatcher extends CommonMessageDispatcher {

    public HostMessageDispatcher(HostSock parentSock) {
        super(parentSock);
    }
    
    public boolean HostMessageDispath(String ins) {
        String cmd;
        cmd = "$DIFFERENTVERSION:";
        if (ins.startsWith(cmd)) {
            core().insertMessage(Tools.parseLocale(21,
                    new String[]{GameCore.sVersion, ins.substring(cmd.length())}), Color.RED);
            return true;
        }
        cmd = "$WATCHCHAT:";
        if (ins.startsWith(cmd)) {
            core().insertMessage(ins.substring(cmd.length()), new Color(120, 60, 0));
            mParentSock.send(mParentSock.getSocket(), ins);
            return true;
        }
        cmd = "$GIVEMECURRENT:";
        if (ins.startsWith(cmd)) {
            core().sendCurrent();
            return true;
        }
        return false;
    }

    @Override
    public void dispatch(String instr) {
        if (HostMessageDispath(instr)) {
            return;
        }
        commonMessageDispath(instr, true);
    }

}

